<?php
define('FPDF_FONTPATH', 'font/');
require('./font/fpdf.php');
include("include/config.inc.php");
include("amountToWords.php");

{
  $pdf=new FPDF('P','mm','A4');   //Create new pdf file
  $pdf->Open();     //Open file
  $pdf->SetAutoPageBreak(false);  //Disable automatic page break
  $pdf->AddPage();  //Add first page

  
  $i         = 0; 
  $rowHeight = 6;
  $yAxis     = 5;

  $yAxis = $yAxis + $rowHeight;
  
  $pdf->SetDrawColor(255, 51, 51);
  $pdf->SetFont('Arial', '', 12);
  $pdf->SetXY(5,5);
  $pdf->Cell(98, 60, '', 1, 0, 'L', 0);
  $pdf->SetXY(4,4);
  $pdf->Cell(100, 62, '', 1, 0, 'L', 0);
 
  $pdf->AddFont('Saumil_guj2', '', 'Saumil_guj2.php');
  $pdf->SetFont('Saumil_guj2', '', 25);
  $pdf->SetTextColor(255,51,51);
  $pdf->SetXY(5,2);
  $pdf->Cell(95, 15, 'iSavaSaikta fa[naansa', 0, 0, 'C', 0);
  
  $pdf->SetFillColor(255, 153, 153);
  $pdf->SetTextColor(0, 0, 102);
  $pdf->SetFont('Saumil_guj2', '', 13);
  $pdf->SetXY(6,15);
  $pdf->RoundedRect(6,15,20,6,3.0,'B');
  $pdf->Cell(20, 6, 'naama :', 0, 0, 'L', 0);
  $pdf->SetXY(6,22);
  $pdf->RoundedRect(6,22,20,6,3.0,'B');
  $pdf->Cell(20, 6, 'vaJna :', 0, 0, 'L', 0);
  $pdf->SetXY(6,29);
  $pdf->RoundedRect(6,29,20,6,3.0,'B');
  $pdf->Cell(20, 6, 'vastau :', 0, 0, 'L', 0);
  $pdf->SetXY(6,36);
  $pdf->RoundedRect(6,36,20,6,3.0,'B');
  $pdf->Cell(20, 6, 'taarIKa :', 0, 0, 'L', 0);
  $pdf->SetXY(6,43);
  $pdf->RoundedRect(6,43,20,6,3.0,'B');
  $pdf->Cell(20, 6, 'Aapaola rkma :', 0, 0, 'L', 0);
  $pdf->SetXY(6,50);
  $pdf->RoundedRect(6,50,20,6,3.0,'B');
  $pdf->Cell(20, 6, 'sarnaamau :', 0, 0, 'L', 0);
  $pdf->SetXY(6,57);
  $pdf->RoundedRect(6,57,20,6,3.0,'DF');
  $pdf->Cell(20, 6, 'sahI :', 0, 0, 'L', 0);

  //table header part end 
  $selectChallan = "SELECT party.partyName,party.address,loan.loanId,DATE_FORMAT(loan.loanDate ,'%d-%m-%Y') AS loanDate,
                           loan.weight,item.itemName,loan.loanAmount,loan.loanVarNo
                      FROM loan
                 LEFT JOIN party ON party.partyId = loan.partyId
                 LEFT JOIN item ON item.itemId = loan.itemId";
  $selectChallanRes = mysql_query($selectChallan);
  while($selectRow  = mysql_fetch_array($selectChallanRes))
  {                                             
    $loanId    = $selectRow['loanId'];
    $partyName = $selectRow['partyName'];
    $address   = $selectRow['address'];
    $loanDate   = $selectRow['loanDate'];
    $weight   = $selectRow['weight'];
    $itemName   = $selectRow['itemName'];
    $loanAmount   = $selectRow['loanAmount'];
    $loanVarNo   = $selectRow['loanVarNo'];
  }
  
  
  
  $pdf->SetTextColor(0, 0, 102);
  $pdf->SetFont('arial','', 10);
  $pdf->SetXY(30,15);
  $pdf->RoundedRect(28,15,73,6,3.0,'B');
  $pdf->Cell(72, 8, $partyName, 0, 0, 'L', 0);
  $pdf->SetXY(30,22);
  $pdf->RoundedRect(28,22,73,6,3.0,'B');
  $pdf->Cell(175, 8, $weight, 0, 0, 'L', 0);
  $pdf->SetXY(30,29);
  $pdf->RoundedRect(28,29,73,6,3.0,'B');
  $pdf->Cell(75, 8, $itemName, 0, 0, 'L', 0);
  $pdf->SetXY(30,36);
  $pdf->RoundedRect(28,36,73,6,3.0,'B');
  $pdf->Cell(75, 8, $loanDate, 0, 0, 'L', 0);
  $pdf->SetXY(30,43);
  $pdf->RoundedRect(28,43,73,6,3.0,'B');
  $pdf->Cell(175, 8, $loanAmount, 0, 0, 'L', 0);
  $pdf->SetXY(30,50);
  $pdf->RoundedRect(28,50,73,6,3.0,'B');
  $pdf->Cell(175, 8, $address, 0, 0, 'L', 0);
  $pdf->SetXY(30,50);
  $pdf->RoundedRect(28,57,73,6,3.0,'B');
  $pdf->Cell(175, 8, '', 0, 0, 'L', 0);
  
  //<!---------------------------------box 2 ------------------------------------------->
  
  $pdf->SetDrawColor(255, 51, 51);
  $pdf->SetFont('Arial', '', 12);
  $pdf->SetXY(107,4);
  $pdf->Cell(98, 62, '', 1, 0, 'L', 0);
  $pdf->SetXY(108,5);
  $pdf->Cell(96, 60, '', 1, 0, 'L', 0);
  
  $pdf->SetTextColor(0, 0, 102);
  $pdf->SetFont('arial','', 70);
  $pdf->SetXY(120,35);
  $pdf->Cell(72, 8, $loanVarNo, 0, 0, 'C', 0);
  
  $pdf->SetFont('Saumil_guj2', '', 40);
  $pdf->SetTextColor(0,0,102);
  $pdf->SetXY(130,2);
  $pdf->RoundedRect(111,7,90,12,3.5,'DF');
  $pdf->Cell(50, 22, 'Kaataa naM.', 0, 0, 'C', 0);
  
  
  $pdf->Output();
}
?>